Skip to main content

πŸ”— Linked List

Linked lists test pointer dexterity. Almost every problem reduces to: traverse with a dummy head, manipulate prev/curr/next carefully, or run two pointers at different speeds.

This category contains 27 problems. Use the patterns below to recognize what's being asked, then jump to the problem list at the bottom.


🧠 Key Patterns​

  • Dummy Head β€” Simplifies edge cases when the head itself changes (merge, remove-Nth).
  • Fast & Slow Pointers β€” Cycle detection, find middle, kth-from-end.
  • In-place Reversal β€” prev/curr/next swap β€” the classic interview move.
  • Merge Two / K Sorted Lists β€” Two pointers (k=2) or min-heap (k>2).
  • Recursion on Lists β€” Many problems become a 3-line recursive solution.

⚠️ Common Pitfalls​

  • Losing the list β€” always cache next before reassigning pointers.
  • Off-by-one with n + 1 gap in the two-pointer remove-Nth pattern.
  • Forgetting to break the cycle when detecting and removing one.

πŸ“š Study Resources​

πŸ“Ί Videos​

πŸ“– Books​

  • Cracking the Coding Interview β€” Ch. 2 (Linked Lists)
  • Elements of Programming Interviews β€” Ch. 7

🌐 Articles & References​


πŸ’» All Linked List Problems​